package com.gxa.service.impl;

import com.gxa.common.R;
import com.gxa.mapper.DocumentMapper;
import com.gxa.pojo.Document;
import com.gxa.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: 张剑宇
 * Date: 2021/12/02 18:38
 * Description:
 * Version: V1.0
 */
@Service
public class DocumentServiceImpl implements DocumentService {
    @Autowired(required = false)
    private DocumentMapper documentMapper;


    @Override
    @Transactional(rollbackFor = Exception.class)
    public R addDocument(Document document) {
        documentMapper.addDocumentMapper(document);
        R r=new R();
        r.setCode(200);
        r.setMsg("添加成功");
        return r;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public R deleteDocument(Integer document_id) {
        documentMapper.deleteDocumentMapper(document_id);
        R r=new R();
        r.setCode(200);
        r.setMsg("删除成功");
        return r;
    }

    @Override
    public R queryDocument(Integer documentary_id) {
        List<Document> list=documentMapper.queryDocumentMapper(documentary_id);
        R r=new R();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(list);
        return r;
    }

    @Override
    public R queryDocumentByRepair(Integer repair_id) {
        List<Document> list=documentMapper.queryDocumentMapperByRepair(repair_id);
        R r=new R();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(list);
        return r;
    }
}
